{include file="public/header" /}
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
    <legend>角色{notempty name="role"}修改{else/ }添加{/notempty}</legend>
</fieldset>

<form class="layui-form" action="" method="post">

    {notempty name="role"} <input type="hidden" name="id" value="{$role.id}"> {/notempty}

    <div class="layui-form-item">
        <label class="layui-form-label">角色名称</label>
        <div class="layui-input-block">
            <input type="text" name="role_name" required {notempty name="role"} value="{$role.role_name}" {/notempty} lay-verify="required" placeholder="请输入管理员账号" autocomplete="off" class="layui-input">
        </div>
    </div>

    <blockquote class="layui-elem-quote">分配权限</blockquote>

    <div class="layui-tab">
        <ul class="layui-tab-title">
            {foreach $list as $k=>$v}
            <li {if $k==0} class="layui-this" {/if}>{$v.node_name}</li>

            {/foreach}
        </ul>

        <div class="layui-tab-content">
            {foreach $list as $k=>$v}

            <div {if $k==0} class="layui-tab-item  layui-show" {else /}class="layui-tab-item" {/if}>
            {notempty name="v.children"}
                {foreach $v.children as $v1}
            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                <legend>{$v1.node_name}</legend>
            </fieldset>

                <input type="checkbox" name="node_id[]"  value="{$v.id}/{$v1.id}" {notempty name="r_n"}{if in_array($v1.id,$r_n)}checked {/if}{/notempty} title="{$v1.node_name}">
                <br><br>
            <fieldset class="layui-elem-field">
                <legend>{$v1.node_name}子节点</legend>
                {notempty name="v1.children"}
                    {foreach $v1.children as $v2}
                        <div class="layui-field-box">
                            <input type="checkbox"  name="node_id[]" value="{$v.id}/{$v1.id}/{$v2.id}"  {notempty name="r_n"}{if in_array($v2.id,$r_n)}checked {/if}{/notempty} title="{$v2.node_name}">
                        </div>
                    {/foreach}
                {else /}
                <br>
                <legend>子节点为空</legend>
                <br>
                {/notempty}
            </fieldset>
            <hr class="layui-bg-red">
                {/foreach}
            {else /}
            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
            <br>
            <legend style="font-size: 24px">子节点为空</legend>
            <br>
            </fieldset>
            {/notempty}
            </div>
        {/foreach}
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>



<script>
    //Demo
    layui.use('form', function(){
        var form = layui.form;

        //监听提交
        form.on('submit(formDemo)', function(data){

        });
    });
</script>

{include file="public/footer" /}